﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DevTool.Operation
{
    public class TextFactoryOperation
    {
        public static void TextChanged(TextBox textBoxSource, TextBox textBoxTarget)
        {
            var t21sp = textBoxSource.Text.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None).ToList();
            if (t21sp != null && t21sp.Count() > 0)
            {
                for (int i = 0; i < t21sp.Count(); i++)
                {
                    var tt = t21sp[i].Split('、');
                    if (tt.Length > 1)
                    {
                        textBoxTarget.Text += $"{tt[1]}\r\n";
                    }
                }
            }
        }


        public static string TextChangedHHJDW(string textBoxSource, string textBoxDWBS)
        {
            string textBoxTarget = "";
            var t21sp = textBoxSource.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None).ToList();
            if (t21sp != null && t21sp.Count() > 0)
            {
                for (int i = 0; i < t21sp.Count(); i++)
                {
                    var tt = t21sp[i];
                    if (tt.Length > 1)
                    {
                        textBoxTarget += $"{i + 1}{textBoxDWBS}{tt}\r\n";
                    }
                }
            }
            return textBoxTarget;
        }

        public static string TextChangedQCDW(string textBoxSource, string textBoxDWBS)
        {
            string textBoxTarget = "";
            var t21sp = textBoxSource.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None).ToList();
            if (t21sp != null && t21sp.Count() > 0)
            {
                for (int i = 0; i < t21sp.Count(); i++)
                {
                    var tt = t21sp[i].Split(new string[] { textBoxDWBS }, StringSplitOptions.None);
                    if (tt.Length > 1)
                    {
                        textBoxTarget += $"{tt[1]}\r\n";
                    }
                }
            }
            return textBoxTarget;
        }

        public static string TextChangedCXDW(string textBoxSource, string textBoxDWBS)
        {
            string textBoxTarget = "";
            var zd = textBoxSource.Split(new string[] { "\r\n" }, StringSplitOptions.None);
            for (int i = 0; i < zd.Length; i++)
            {
                string item = zd[i];
                if (item.Length > 0)
                {
                    var zde = item.Split(new string[] { textBoxDWBS }, StringSplitOptions.None);
                    if (zde.Count() >= 2)
                    {
                        textBoxTarget += (i + 1) + textBoxDWBS + zde[1] + "\r\n";
                    }
                }
            }
            return textBoxTarget;
        }
    }
}
